class DoubleSlabRenderer : public IBlockRenderer
{
public:
	ITexture *Texture;

	DoubleSlabRenderer(ITexture *texture) :
		Texture(texture)
	{
	}

	int GetTypeData(const int &data)
	{
		return data & ~0x08;
	}

	void PassOtherBlock(Schematic *schematic, RendererBase *renderer, const byte &id, const byte &data, const Point3i &position)
	{
		Block block(id, data);
		//renderer->GetBlockRenderer(block)->Render(schematic, renderer, block, position);
	}

	void Render(Schematic *schematic, RendererBase *renderer, const Block &block, const Point3i &position)
	{
		Point2i sideTexture, topTexture(-1, -1);
		byte d = (byte)(block.Data & ~0x08);

		if (block.ID == 43 || block.ID == 125)
		{
			if (block.ID == 43)
			{
				switch (d)
				{
					case 0:
						sideTexture = Point2i(5 * 16, 0);
						topTexture = Point2i(6 * 16, 0);
						break;
					case 1:
						PassOtherBlock(schematic, renderer, 24, 0, position);
						return;
						//texturePos = Point2i(0, 12 * 16);
						//break;
					case 2:
						sideTexture = Point2i(4 * 16, 0);
						break;
					case 3:
						sideTexture = Point2i(0, 1 * 16);
						break;
					case 4:
						sideTexture = Point2i(7 * 16, 0);
						break;
					case 5:
						sideTexture = Point2i(6 * 16, 3 * 16);
						break;
					case 6:
						sideTexture = Point2i(6 * 16, 0);
						topTexture = Point2i(6 * 16, 0);
						break;
				}
			}
			else
			{
				PassOtherBlock(schematic, renderer, 5, d, position);
				return;
			}

			if (topTexture.X == -1)
				topTexture = sideTexture;

			renderer->Draw(Box(Texture).SetAll(sideTexture).SetTop(topTexture).SetBottom(topTexture));
		}
		else
		{
			bool upsideDown = (block.Data & 0x08) != 0;

			if (block.ID == 44)
			{
				switch (d)
				{
					case 0:
					case 6:
						sideTexture = Point2i(5 * 16, 0);
						topTexture = Point2i(6 * 16, 0);
						break;
					case 1:
						sideTexture = Point2i(0, 12 * 16);
						topTexture = Point2i(0, 11 * 16);
						break;
					case 2:
						sideTexture = Point2i(4 * 16, 0);
						break;
					case 3:
						sideTexture = Point2i(0, 1 * 16);
						break;
					case 4:
						sideTexture = Point2i(7 * 16, 0);
						break;
					case 5:
						sideTexture = Point2i(6 * 16, 3 * 16);
						break;
				}
			}
			else
			{
				switch (d)
				{
					case 0:
					default:
						sideTexture = Point2i(4 * 16, 0);
						break;
					case 1:
						sideTexture = Point2i(6 * 16, 12 * 16);
						break;
					case 2:
						sideTexture = Point2i(6 * 16, 13 * 16);
						break;
					case 3:
						sideTexture = Point2i(7 * 16, 12 * 16);
						break;
				}
			}

			Point3i position(0, 0, 0), bounds(16, 8, 16);

			if (topTexture.X == -1)
				topTexture = sideTexture;

			if (!upsideDown)
			{
				position.Y += 8;
				sideTexture.Y += 8;
			}

			renderer->Draw(Box(Texture, bounds, position).SetAll(sideTexture).SetTop(topTexture).SetBottom(topTexture));
		}
	}
};